home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
-
- main()
- {
- char* remote_host;
-
- printf("Content-type: text/html\n\n");
-
- printf("<HTML>\n");
- printf("<HEAD><TITLE>CGI Script How-to: Test Script</TITLE></HEAD>\n");
- printf("<BODY>\n");
-
- printf("<H1>CGI Script How-to<BR>determine the client machine's name</H1>\n");
-
- remote_host = getenv("REMOTE_HOST");
-
- /* Check the value */
-
- if (remote_host == NULL)
- {
- /* REMOTE_HOST is undefined so let's try REMOTE_ADDR */
- remote_host = getenv("REMOTE_ADDR");
- if (remote_host == NULL)
- {
- /* REMOTE_ADDR is also undefined so we give up */
- remote_host = "somewhere on the Internet";
- }
- }
-
- /* print the remote host (or address) and exit */
-
- printf("Hello, you are a user from <B>%s</B>\n", remote_host);
-
- printf("</BODY></HTML>\n");
- exit(0);
- }
-
- /*
- * end of testhost.c
- */
-